mui.init({
	swipeBack:false //启用右滑关闭功能
});
if(window.plus){
    plusReady();
}else{
    document.addEventListener('plusready',plusReady,false);
}
//目前就一个系统 先写死            
function plusReady(){
	
    var token = plus.storage.getItem("token");
	if(token==null||token==""){
		return;
	}else{
	   mui.ajax(baseServerAdrr+'/mobile/getUserConfig',{
	      data: {
	   		token:token,
	   		xtbh:'xt01'
	      },
	      dataType:'json',//服务器返回json格式数据
	      type:'post',//HTTP请求类型
	      timeout:30000,//超时时间设置为10秒；
	      success:function(data){
		      if(data.code=='success'){
		      	var zzjg=document.getElementById('zzjg');
		      	var zzjglabel=document.getElementById('zzjglable');
		      	var config_title=document.getElementById('config_title');
		      	var formvar=document.getElementById('pan_val');
                if(data.message.loginzz==undefined){
                	config_title.innerHTML="(未配置)";
                	formvar.classList.remove('pan_hide_element');
                	zzjg.classList.add('pan_hide_element');
                }else{  	
                	config_title.innerHTML="(已配置)";
                	zzjglabel.innerHTML=""+data.message.loginzz+"-"+data.message.loginzzmc;
                	formvar.classList.add('pan_hide_element');
                	zzjg.classList.remove('pan_hide_element');
                }
		      }else{
		   	    mui.toast(data.message);
		   	    setTimeout(function(){
		   	    	panUtil.ReLogin();
		   	    },1000);
		     }
	      },
	      error:function(xhr,type,errorThrown){
		     //异常处理；
		   mui.toast('服务器异常登录失败! sysConfig.js');
	    }
	   });      	
    }
}

var removeConfig=function(xtbh){
	var token = plus.storage.getItem("token");
	if(token==null||token==""){
		return;
	}else{
	   mui.ajax(baseServerAdrr+'/mobile/removeUserConfig',{
	      data: {
	   		token:token,
	   		xtbh:xtbh
	      },
	      dataType:'json',//服务器返回json格式数据
	      type:'post',//HTTP请求类型
	      timeout:30000,//超时时间设置为10秒；
	      success:function(data){
		      if(data.code=='success'){
		      	var zzjg=document.getElementById('zzjg');
		      	var config_title=document.getElementById('config_title');
		      	var formvar=document.getElementById('pan_val');
               
                config_title.innerHTML="(未配置)";
                formvar.classList.remove('pan_hide_element');
                zzjg.classList.add('pan_hide_element');
		      }else{
		   	    mui.toast(data.message);
		   	    setTimeout(function(){
		   	    	panUtil.ReLogin();
		   	    },1000);
		     }
	      },
	      error:function(xhr,type,errorThrown){
		     //异常处理；
		   mui.toast('服务器异常登录失败! sysConfig.js');
	    }
	   });      	
    }
}


var validateUser=function(xtbh){
	var token = plus.storage.getItem("token");
	
	var username=eval(document.getElementById('username')).value;
    var password=eval(document.getElementById('password')).value;
    
	if(token==null||token==""){
		return;
	}else{
	   mui.ajax(baseServerAdrr+'/mobile/validateUser',{
	      data: {
	   		token:token,
	   		xtbh:xtbh,
	   		username:username,
	   		password:password
	      },
	      dataType:'json',//服务器返回json格式数据
	      type:'post',//HTTP请求类型
	      timeout:30000,//超时时间设置为10秒；
	      success:function(data){
		      if(data.code=='success'){
		      	  var zzselect =document.getElementById('zzselect');
		      	  var zzselectall=document.getElementById('zzselectall');
		      	  zzselect.innerHTML='';
		      	  zzselectall.classList.remove('pan_hide_element')
		      	  var datamess=data.message;
		      	  var innelhtml='';
		      	  for(var i=0;i<datamess.length;i++){
		      	  	innelhtml+="<option value=\""+datamess[i].zzjg+"\">"+datamess[i].zzjgmc+"</option>";
		      	  }
		      	  zzselect.innerHTML=innelhtml;
		      	  
		      	  var validate =document.getElementById('validate');
		      	  var addUser=document.getElementById('addUser');
		      	  validate.classList.add('pan_hide_element');
		      	  addUser.classList.remove('pan_hide_element');
		      	  
		      }else{
		   	    mui.toast(data.message);
		   	    setTimeout(function(){
		   	    	panUtil.ReLogin();
		   	    },1000);
		     }
	      },
	      error:function(xhr,type,errorThrown){
		     //异常处理；
		   mui.toast('服务器异常登录失败! sysConfig.js');
	    }
	   });      	
    }
}


var addUserfunc=function(xtbh){
	var token = plus.storage.getItem("token");
	
	var username=eval(document.getElementById('username')).value;
	var password=eval(document.getElementById('password')).value;
    var zzjg=eval(document.getElementById('zzselect')).value;
    
    var selectIndex = document.getElementById("zzselect").selectedIndex;//获得是第几个被选中了
    var zzjgmc = document.getElementById("zzselect").options[selectIndex].text ;
	if(token==null||token==""){
		return;
	}else{
	   mui.ajax(baseServerAdrr+'/mobile/addUser',{
	      data: {
	   		token:token,
	   		xtbh:xtbh,
	   		username:username,
	   		password:password,
	   		zzjg:zzjg,
	   		zzjgmc:zzjgmc
	      },
	      dataType:'json',//服务器返回json格式数据
	      type:'post',//HTTP请求类型
	      timeout:30000,//超时时间设置为10秒；
	      success:function(data){
		      if(data.code=='success'){
		      	  config_title.innerHTML="(已配置)";
                  zzjglabel.innerHTML=""+zzjg+"-"+zzjgmc;
                  formvar.classList.add('pan_hide_element');
                  zzjg.classList.remove('pan_hide_element');
		      }else{
		   	    mui.toast(data.message);
		   	    setTimeout(function(){
		   	    	panUtil.ReLogin();
		   	    },1000);
		     }
	      },
	      error:function(xhr,type,errorThrown){
		     //异常处理；
		   mui.toast('服务器异常登录失败! sysConfig.js');
	    }
	   });      	
    }
}